package top.misspro.valheimadminsocket.annotation;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import sun.security.ec.point.ProjectivePoint;
import top.misspro.valheimadminsocket.server.Client;
import top.misspro.valheimadminsocket.server.ServerContains;

/**
 * 注解切面
 *
 * @author Evan
 */
@Aspect
@Component
@SuppressWarnings("unused")
@Slf4j
public class ActionAspect {


    @Pointcut("@annotation(Action)")
    public void annotationPointcut() {
    }

    @Before("annotationPointcut()")
    public void before(JoinPoint joinPoint) {
        Object[] args = joinPoint.getArgs();
        Signature signature = joinPoint.getSignature();
        String methodName = signature.getName();

        String channelId = ServerContains.getThreadLocal();
        Client client = ServerContains.getClient(channelId);

        //TODO 连接SSH

    }


    @AfterReturning("annotationPointcut()")
    public void after(JoinPoint joinPoint) {
        //TODO 释放SSH

    }

}
